package com.异常.www;

import java.util.InputMismatchException;
import java.util.Scanner;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: lenovo
 * Date: 2022-07-16
 * Time: 8:47
 */
public class Test {
    private static void func(){
        int[] arr = {1,2,3};
        System.out.println(arr[100]);
        throw  new ArithmeticException();
    }
    public static void main(String[] args) {
            func();

        System.out.println("after try-catch");
        throw new ArrayIndexOutOfBoundsException();
    }
//public static int getData(){
//    try (Scanner scanner = new Scanner(System.in)) {
//        int data = scanner.nextInt();
//        return data;
//    } catch (InputMismatchException e) {
//        e.printStackTrace();
//    } finally {//finally一定会被执行
//        System.out.println("finally中代码");
//        //释放输入流资源
//    }
//    return 0;
//}
//    public static void main(String[] args) {
//        int data = getData();
//        System.out.println(data);
//    }
}
